<link href="<?php echo base_url('theme/css/frontend/company-add.css'); ?>" rel="stylesheet">
<link href="<?php echo base_url('theme/css/frontend/account-manager.css'); ?>" rel="stylesheet">
<link href="<?php echo base_url('theme/css/frontend/search.css'); ?>" rel="stylesheet">
<link href="<?php echo base_url(); ?>theme/third_party/calendar/css/calendar.css" type="text/css" rel="stylesheet">
<script src="<?php echo base_url('theme/js/frontend/jquery.trialPhoto.js'); ?>" type="text/javascript"></script>
<script src="<?php echo base_url('theme/js/frontend/jquery.ajax.upload.js'); ?>"></script>
<script src="<?php echo base_url('theme/js/frontend/jquery.validate.js'); ?>"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $("#dialog-confirm").dialog({
            resizable: false,
            autoOpen: false,
            modal: true,
            buttons: {
                "Huỷ bỏ sự kiện": function() {
                    window.location = "/event/delete/" + $('input[name=id]').val();
                },
                "Không huỷ bỏ": function() {
                    $(this).dialog("close");
                }
            }
        });
    });
    function loadEvent(year, month, day) {
        $('#event-content').load('/event/eventinfo/' + year + '/' + month + '/' + day, function() {
            $.getScript('<?php echo base_url('theme/js/frontend/js.js'); ?>', function() {
                eventPopup('event');
            });
        });
    }

    function cancelevent(id) {
        var r = confirm("Bạn có chắc chắn muốn huỷ sự kiện này?");
        if (r == true) {
            window.location = "/event/delete/" + $('input[name=id]').val();
        }
    }

    function join(event_id) {
        $.ajax({
            url: '/event/join/' + event_id,
            type: "POST",
            dataType: 'json',
            success: function(data) {
                if(typeof(data['error']) != "undefined") {
                    $("button[name=join]").hide();
                    $("button[name=notjoin]").hide();
                    $(".join-message").text(data['message']);  
                } else {
                    $("button[name=join]").hide();
                    $("button[name=notjoin]").hide();
                    $(".join-message").text("Đăng ký tham gia thành công.");
                }
            }
        });
    }

    function notjoin(event_id) {
        $.ajax({
            url: '/event/notjoin/' + event_id,
            type: "POST",
            dataType: 'json',
            success: function(data) {
                if(typeof(data['error']) != "undefined") {
                    $("button[name=join]").hide();
                    $("button[name=notjoin]").hide();
                    $(".join-message").text(data['message']);                    
                } else {
                    $("button[name=join]").hide();
                    $("button[name=notjoin]").hide();
                    $(".join-message").text("Từ chối tham gia thành công.");
                }
            }
        });
    }

    function change(id, type) {
        if (type == 1) {
            window.location = "/event/company/" + id;
        } else if (type == 2) {
            window.location = "/event/booth/" + id;
        }
    }
</script>
<div class="management-container booth-container search-container">
    <?php echo validation_errors('<div class="alert alert-error">', '</div>'); ?>
    <h3 style="color:black;">Sự kiện</h3>
    <hr class="hr" />
    <div class="management-wrapper">
        <div style="min-height:65px;">
            <button class="btn btn-event" style="width:200px" type="button" onclick="window.location = '/event/company';">
                Tạo sự kiện doanh nghiệp
            </button>
            <button class="btn btn-event" style="width:200px" type="button" onclick="window.location = '/event/booth';">
                Tạo sự kiện gian hàng
            </button>
            <button class="btn btn-primary btn-event" type="button" onclick="window.location = '/event/';">
                Quản lý sự kiện
            </button>
        </div>
        <div id="index-search-top">
            <div class="search-left">
                <h4>Sự kiện trong tháng</h4>
            </div>
            <div class="search-right">
                <input type="hidden" name="prev_month" value="<?php echo $prev_month; ?>" />
                <input type="hidden" name="next_month" value="<?php echo $next_month; ?>" />
                <div class="index_arrow_left">
                    <span class="index-link-arrow-left" onclick="$('#calendar').load('/event/calendar/' + $('input[name=prev_month]').val());
        $('.search-right').load('/event/month/' + $('input[name=prev_month]').val());"></span>
                </div>
                <div class="search-right-content">
                    <h4> <?php
                        echo $current_month;
                        ?> </h4>
                </div>
                <div class="index_arrow_right">
                    <span class="index-link-arrow-right" onclick="$('#calendar').load('/event/calendar/' + $('input[name=next_month]').val());
        $('.search-right').load('/event/month/' + $('input[name=next_month]').val());"></span>
                </div>
            </div>
        </div>
        <hr class="hr" style="width: 796px;">
        <div class="management-block">
            <div id="calendar">
                <?php
                echo $calendar;
                ?>
            </div>
            <div id="event-content">

            </div>
        </div>
    </div>
    <div id="dialog-confirm" title="Huỷ bỏ sự kiện?">
        <p>
            <span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>
            Bạn có chắc chắn muốn huỷ bỏ sự kiện này?
        </p>
    </div>
    <!-- /management-wrapper -->
</div>